#include<iostream>
using namespace std;
int a[1000010];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++) cin >> a[i];
	int max = 0;
	int sum = 0;
	for (int left = 0,right=0;right < n;right++)
	{
		if ((right - left + 1) > m)
		{
			sum -= a[left];
			left++;
		}
		if (sum < 0)
		{
			left = right;
			right--;
			sum = 0;
			continue;
		}
		sum += a[right];
		if (sum > max)max = sum;
	}
	cout << max << endl;
	return 0;
}